﻿//文件指定编译编码UTF-8
#pragma execution_character_set("utf-8")

/**
*
* @file:    menu.h
* @brief:
* @author:  sanshi522@163.com
* @date:    2024-11-05  11:38
*
*
*
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 2 of the License, or
*  (at your option) any later version.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License along
*  with this program; if not, write to the Free Software Foundation, Inc.,
*  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/

#ifndef MENU_H
#define MENU_H
#include "qbaseentity.h"
/**
 * @brief 菜单实体类
 */
class Menu: public QBaseEntity
{
    Q_OBJECT
    // 使用 Q_PROPERTY 宏定义属性
    Q_PROPERTY(uint64_t id READ getId WRITE setId)
    Q_PROPERTY(QString name READ getName WRITE setName)
    Q_PROPERTY(QString path READ getPath WRITE setPath)
    Q_PROPERTY(QString redirect READ getRedirect WRITE setRedirect)
    Q_PROPERTY(QString component READ getComponent WRITE setComponent)
    Q_PROPERTY(uint64_t parentId READ getParentId WRITE setParentId)

    // 元信息
    Q_PROPERTY(QString activeIcon READ getActiveIcon WRITE setActiveIcon)
    Q_PROPERTY(QString activePath READ getActivePath WRITE setActivePath)
    Q_PROPERTY(bool affixTab READ getAffixTab WRITE setAffixTab)
    Q_PROPERTY(int32_t affixTabOrder READ getAffixTabOrder WRITE setAffixTabOrder)
    Q_PROPERTY(QStringList authority READ getAuthority WRITE setAuthority)
    Q_PROPERTY(QString badge READ getBadge WRITE setBadge)
    Q_PROPERTY(QString badgeType READ getBadgeType WRITE setBadgeType)
    Q_PROPERTY(QString badgeVariants READ getBadgeVariants WRITE setBadgeVariants)
    Q_PROPERTY(bool hideChildrenInMenu READ getHideChildrenInMenu WRITE setHideChildrenInMenu)
    Q_PROPERTY(bool hideInBreadcrumb READ getHideInBreadcrumb WRITE setHideInBreadcrumb)
    Q_PROPERTY(bool hideInMenu READ getHideInMenu WRITE setHideInMenu)
    Q_PROPERTY(bool hideInTab READ getHideInTab WRITE setHideInTab)
    Q_PROPERTY(QString icon READ getIcon WRITE setIcon)
    Q_PROPERTY(QString iframeSrc READ getIframeSrc WRITE setIframeSrc)
    Q_PROPERTY(bool ignoreAccess READ getIgnoreAccess WRITE setIgnoreAccess)
    Q_PROPERTY(bool keepAlive READ getKeepAlive WRITE setKeepAlive)
    Q_PROPERTY(QString link READ getLink WRITE setLink)
    Q_PROPERTY(bool loaded READ getLoaded WRITE setLoaded)
    Q_PROPERTY(int32_t maxNumOfOpenTab READ getMaxNumOfOpenTab WRITE setMaxNumOfOpenTab)
    Q_PROPERTY(bool menuVisibleWithForbidden READ getMenuVisibleWithForbidden WRITE setMenuVisibleWithForbidden)
    Q_PROPERTY(bool openInNewWindow READ getOpenInNewWindow WRITE setOpenInNewWindow)
    Q_PROPERTY(int32_t order READ getOrder WRITE setOrder)
    Q_PROPERTY(QString query READ getQuery WRITE setQuery)
    Q_PROPERTY(QString title READ getTitle WRITE setTitle)

public:
    Menu(QObject *parent = nullptr);
    Menu(uint64_t m_id,QString m_name,QString m_path,QString m_redirect,QString m_component,uint64_t m_parentId,QString m_icon,uint32_t m_order,QString m_title,QStringList authority=QStringList("admin"));
    ~Menu();

    uint64_t getId() const;
    void setId(const uint64_t &value);

    QString getName() const;
    void setName(const QString &value);

    QString getPath() const;
    void setPath(const QString &value);

    QString getRedirect() const;
    void setRedirect(const QString &value);

    QString getComponent() const;
    void setComponent(const QString &value);

    uint64_t getParentId() const;
    void setParentId(const uint64_t &value);

    QString getActiveIcon() const;
    void setActiveIcon(const QString &value);

    QString getActivePath() const;
    void setActivePath(const QString &value);

    bool getAffixTab() const;
    void setAffixTab(bool value);

    int32_t getAffixTabOrder() const;
    void setAffixTabOrder(const int32_t &value);

    QStringList getAuthority() const;
    void setAuthority(const QStringList &value);
    void appendAuthority(const QStringList &value);
    void appendAuthority(const QString &value);

    QString getBadge() const;
    void setBadge(const QString &value);

    QString getBadgeType() const;
    void setBadgeType(const QString &value);

    QString getBadgeVariants() const;
    void setBadgeVariants(const QString &value);

    bool getHideChildrenInMenu() const;
    void setHideChildrenInMenu(bool value);

    bool getHideInBreadcrumb() const;
    void setHideInBreadcrumb(bool value);

    bool getHideInMenu() const;
    void setHideInMenu(bool value);

    bool getHideInTab() const;
    void setHideInTab(bool value);

    QString getIcon() const;
    void setIcon(const QString &value);

    QString getIframeSrc() const;
    void setIframeSrc(const QString &value);

    bool getIgnoreAccess() const;
    void setIgnoreAccess(bool value);

    bool getKeepAlive() const;
    void setKeepAlive(bool value);

    QString getLink() const;
    void setLink(const QString &value);

    bool getLoaded() const;
    void setLoaded(bool value);

    int32_t getMaxNumOfOpenTab() const;
    void setMaxNumOfOpenTab(const int32_t &value);

    bool getMenuVisibleWithForbidden() const;
    void setMenuVisibleWithForbidden(bool value);

    bool getOpenInNewWindow() const;
    void setOpenInNewWindow(bool value);

    int32_t getOrder() const;
    void setOrder(const int32_t &value);

    QString getQuery() const;
    void setQuery(const QString &value);

    QString getTitle() const;
    void setTitle(const QString &value);
private:
    uint64_t id;
    QString name; /**< 显示名称 */
    QString path; /**< 路由地址 */
    QString redirect; /**< 重定向地址 */
    QString component; /**< 模板路径 */
    uint64_t parentId; /**< 父ID */
    //元信息
    QString title;/**< 标题名称 */
    QString activeIcon;/**<  激活图标（菜单/tab） */
    QString activePath;/**<  当前激活的菜单，有时候不想激活现有菜单，需要激活父级菜单时使用 */
    bool affixTab;/**< 是否固定标签页 */
    int32_t affixTabOrder;/**< 固定标签顺序 */
    QStringList authority;/**< 菜单权限 需要特定的角色标识才可以访问 */
    QString badge;/**< 徽标 */
    QString badgeType;/**< 徽标类型 */
    QString badgeVariants;/**< 徽标颜色 */
    bool hideChildrenInMenu;/**< 当前路由的子级在菜单中不展现 (隐藏子集菜单) */
    bool hideInBreadcrumb;/**< 当前路由在面包屑中不展现 */
    bool hideInMenu;/**< 当前路由在菜单中不展现 */
    bool hideInTab;/**< 当前路由在标签页不展现 */
    QString icon;/**< 图标（菜单/tab） */
    QString iframeSrc;/**< iframe 地址 */
    bool ignoreAccess;/**< 忽略权限可以直接访问 */
    bool keepAlive;/**< 开启KeepAlive缓存 */
    QString link;/**< 外链-跳转路径 */
    bool loaded;/**< 路由是否已经加载过 */
    int32_t maxNumOfOpenTab;/**< 标签页最大打开数量 */
    bool menuVisibleWithForbidden;/**< 重定向到403 */
    bool openInNewWindow;/**< 在新窗口打开 */
    int32_t order;/**< 用于路由->菜单排序 */
    QString query;/**< 菜单所携带的参数 */
};
Q_DECLARE_METATYPE(QList<Menu>) //注册到元数据对象
#endif // MENU_H
